﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestConsole
{
    class Clock : IDisposable
    {
        private Stopwatch watch;
        private string name;
        public Clock(string name)
        {
            this.name = name;
            watch = Stopwatch.StartNew();
        }

        public void Dispose()
        {
            Console.WriteLine("{0}: {1} ms", name, watch.ElapsedMilliseconds);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            MCWorldLibrary.World world = new MCWorldLibrary.World(@"D:\Spel\Minecraft\Server-1.5\world\region");
            MCWorldLibrary.BlockData[, ,] blocks = new MCWorldLibrary.BlockData[256, 256, 16];
            for (int x = 0; x < 256; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    for (int y = 0; y < x; y++)
                    {
                        blocks[x, y, z].BlockType = 17;
                        blocks[x, y, z].DataValue = (byte)(x % 2 == 0 ? 2 : 3);
                    }
                }
            }

            for (int i = 0; i < 256; i++)
            {
                //blocks[0, i, 0] = 35;
                //blocks[31, i, 0] = 35;
                //blocks[31, i, 31] = 35;
                //blocks[0, i, 31] = 35;
            }

            using (Clock c = new Clock("SetBlocks"))
            {
                world.SetBlocks(blocks, 0, 0, 0, true);
                //world.RecalculateHeightmaps();
                world.SaveChanges();
            }

            Console.Read();
        }
    }
}
